package io.renren.modules.subject.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.meta.entity.EventEntity;
import io.renren.modules.subject.dao.CarDao;
import io.renren.modules.subject.entity.CarEntity;
import io.renren.modules.subject.service.CarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service("carService")
public class CarServiceImpl extends ServiceImpl<CarDao, CarEntity> implements CarService {

    @Resource
    private CarDao carDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CarEntity> page = this.page(
                new Query<CarEntity>().getPage(params),
                new QueryWrapper<CarEntity>()
        );
        carDao.selectEventsBySubjectId(1l, "tb_car_event");
        return new PageUtils(page);
    }

    @Override
    public List<EventEntity> selectEventsBySubjectId(Long subjectId) {
        return carDao.selectEventsBySubjectId(subjectId,"tb_car_event");
    }

    @Override
    public int insertSubjectEvent(Long subjectId, Long eventId) {
      return carDao.insertSubjectEvent(subjectId, eventId, "tb_car_event");
    }

}